home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c,comp.lang.c++
- Path: newsfeed.internetmci.com!miwok!linex1!news
- From: mfried@linex.com (Marty Fried)
- Subject: Re: sizeof() question >>> :)
- X-Nntp-Posting-Host: sp12.linex.com
- Message-ID: <31714828.1574068@news.linex.com>
- Sender: news@linex1.linex.com
- Organization: Cirrius Cybernetics Corp
- X-Newsreader: Forte Agent .99e/32.209
- References: <1996Apr12.061927@topaz>
- Date: Sun, 14 Apr 1996 18:51:28 GMT
-
- Once upon a time (OK, it was 12 Apr 96 06:19:27 +1000),
- naderr@topaz.cqu.edu.au wrote:
-
- >Hi,
- >
- >How can I get, with a pointer, the sizeof of an array that is
- >pointed by the pointer ? (No it's not a tounge twister :)
- >
- > while (!done) {
- > ch = getchar();
- > if (cp - *ct < sizeof(XXXXXXX)-1) {
- > *cp++ = ch;
- > } else {
- > beep();
- > }
- > }
-
- You can't do it. The only thing you could do is to use exception
- handling, and copy the characters within a try block until you get
- an exception. I'm not sure if even that will give you the exact size
- or work all the time, although it will prevent an exception from
- causing the program to crash.
-
- I suppose you could also create a pointer class which contains the
- size and pointer as members, and pass the class rather than the
- pointer.
-
- cc: naderr@topaz.cqu.edu.au
-
- _______________________________________________________
- Marty Fried - mfried@linex.com Press Enter to Exit
- San Anselmo, CA -NT message
- (MSVC4 + MFC) && (Win95 || NT);
-